package cn.edu.hubu.hubusmartmedicalsystem.controller;


import cn.edu.hubu.hubusmartmedicalsystem.entity.Device;
import cn.edu.hubu.hubusmartmedicalsystem.service.DeviceService;
import cn.edu.hubu.hubusmartmedicalsystem.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@CrossOrigin
public class DeviceController {

    @Autowired
    private DeviceService deviceService;

    @RequestMapping("/device/getDeviceById")
    ResultVO<Device> getDeviceById(String deviceId){
        // 查询设备请求
        return deviceService.getDeviceById(deviceId);
    }

    @RequestMapping("/device/getAllDevices")
    ResultVO<List<Device>> getAllDevices(){
        // 查询所有设备
        return deviceService.getAllDevices();
    }

    @RequestMapping("/device/addDevice")
    ResultVO<String> addDevice(Device device){
        // 添加设备请求
        return deviceService.addDevice(device);
    }

    @RequestMapping("/device/updateDevice")
    ResultVO<String> updateDevice(Device device){
        // 更新设备信息
        return deviceService.updateDevice(device);
    }

    @RequestMapping("/device/deleteDevice")
    ResultVO<String> deleteDevice(String deviceId){
        // 删除设备请求
        return deviceService.deleteDevice(deviceId);
    }

    @RequestMapping("/device/addDevices")
    ResultVO<String> addDevices(List<Device> devices){
        return deviceService.addDevices(devices); // 批量插入设备
    }

    @RequestMapping("/device/deleteDevices")
    ResultVO<String> deleteDevices(List<String> deviceIds){
        // 批量删除设备
        return deviceService.deleteDevices(deviceIds);
    }

}
